<?php
/**
 * house class.
**/
class House extends EMongoDocument {
	// public $hId;
	public $uid;
	public $hsid;
	public $goods;

	public function getCollectionName() {
		return 'House';
	}
	
	/**
	 * This method have to be defined in every model, like with normal CActiveRecord
	 */
	public static function model($className = __CLASS__) {
		return parent :: model($className);
	}
	
	
	    // Add EEmbeddedArraysBehavior
    public function behaviors()
    {
        return array(
            'embeddedArrays' => array(
                'class'=>'ext.YiiMongoDbSuite.extra.EEmbeddedArraysBehavior',
                'arrayPropertyName'=>'goods',       // name of property, that will be used as an array
                'arrayDocClassName'=>'Goods'    // class name of embedded documents in array
            ),
        );
    }
	
	// /**
     // * This method should return simple array that will define field names for embedded
     // * documents, and class to use for them
     // */ 
    // public function behaviors()
    // {
// 
		// return array(
            // 'embeddedArrays' => array(
                // 'class'=>'ext.YiiMongoDbSuite.extra.EEmbeddedArraysBehavior',
                // 'arrayPropertyName'=>'goods',       // name of property, that will be used as an array
                // 'arrayDocClassName'=>'Goods'    // class name of embedded documents in array
            // ),
        // );
    // }
    
    // // within model class
	// public function embeddedDocuments()
	// {
	    // return array(
	        // 'goods' => 'Goods',
	        // // 'some_other_field_name' => 'AnyEMongoEmbeddedDocumentChildClass',
	    // );
	// }
	
	public static function findByHid($hid) {
		return self :: model()->findByAttributes(array ('_id' => $hid));
	}
	
	public static function findAllByUid($uid) {
		return self :: model()->findAllByAttributes(array ('uid' => $uid));
	}
}
